<div class="QuanLyMenu">
	<div class="Phai">
		<div class="ChuDeDetail">
			<?php
				include_once "../classes/module_bs.php";
				include_once "../classes/thuvienham.php";
				if(!IsAdmin())
					header("Location: index.php");
				$module = new module_bs();
				$data_module = $module->LayDanhSach();
				$MaxIndex = $module->MaxIndex();
			?>
			<h4 align="center">Quản lý Module</h4>
			<table class='DSInProfile' width="90%">
				<tr>
					<th>STT</th>
					<th>Mã Module</th>
					<th>Tên Module</th>
					<th>Mô tả</th>
					<th>Trạng thái</th>
					<th>Vị trí</th>
				</tr>
				<?php
					for($i = 0; $i < count($data_module); $i++)
					{
						echo '<tr>';
							$LinkToggle = "index.php?actionad=module_toggle&id=" . $data_module[$i]['MaModule'] . "&pin=" . $data_module[$i]['PIN'];
							$LinkUpIndex = "index.php?actionad=module_index_up&id=" . $data_module[$i]['MaModule'] . "&pin=" . $data_module[$i]['PIN'];
							$LinkDownIndex = "index.php?actionad=module_index_down&id=" . $data_module[$i]['MaModule'] . "&pin=" . $data_module[$i]['PIN'];
							
							echo '<td width="40px" align="center"><b>' . ($i + 1) . '</b></td>';
							echo '<td width="60px" align="center">' . $data_module[$i]['MaModule'] . '</td>';
							echo '<td width="150px">' . $data_module[$i]['TenModule'] . '</td>';
							echo '<td>' . $data_module[$i]['MoTa'] . '</td>';
							echo '<td width="50px" align="center"><a href="' . $LinkToggle .' " >' . ($data_module[$i]['TrangThai'] == 1 ? '<img src="../data/xuatban.png" />' : '<img src="../data/xuatban_no.png" />') . '</a></td>';
							echo '<td width="70px" align="center">' . (($data_module[$i]['Index'] != $MaxIndex) ? '<a href="' . $LinkDownIndex .' " ><img src="../data/godown.png" /></a> ' : '<img src="../data/none.png" /> ') . $data_module[$i]['Index'] . (($data_module[$i]['Index'] != 1) ? ' <a href="' . $LinkUpIndex .' " ><img src="../data/goup.png" /></a>' : ' <img src="../data/none.png" />') .'</td>';
						echo '</tr>';
					}
				?>
			</table>
		</div>
	</div>
</div>

<script>
	$(document).ready(function(){
		$('.ChuDeDetail').show();
		$('.ChyenMucDetail').hide();
		$('.BaiVietDetail').hide();
		
		$('.CD').addClass('DangChon1');
		$('.CM').removeClass('DangChon1');
		$('.BV').removeClass('DangChon1');
	});
	
	$('.CD').click(function(){
		$('.ChuDeDetail').show();
		$('.ChyenMucDetail').hide();
		$('.BaiVietDetail').hide();
		
		$(this).addClass('DangChon1');
		$('.CM').removeClass('DangChon1');
		$('.BV').removeClass('DangChon1');
	});
	$('.CM').click(function(){
		$('.ChuDeDetail').hide();
		$('.ChyenMucDetail').show();
		$('.BaiVietDetail').hide();
		$(this).addClass('DangChon1');
		$('.CD').removeClass('DangChon1');
		$('.BV').removeClass('DangChon1');
	});
	$('.BV').click(function(){
		$('.ChuDeDetail').hide();
		$('.ChyenMucDetail').hide();
		$('.BaiVietDetail').show();
		$(this).addClass('DangChon1');
		$('.CM').removeClass('DangChon1');
		$('.CD').removeClass('DangChon1');
	});
</script>